import request from '@/utils/request'

// 列表接口
export function postQueryPageList(params) {
  return request({
    url: '/plm-sys/api/baseObjects/queryPageList',
    method: 'post',
    data: {
      pageNo: params.pageNo,
      pageSize: params.pageSize,
      t: {
        name: params.name,
        objectType: params.objectType
      }
    }
  })
}

// 编码规则的下拉框接口
export function postQueryList() {
  return request({
    url: '/plm-sys/api/baseCoderule/queryList',
    method: 'post',
    data: {
      status: '2'
    }
  })
}

// 新增接口
export function postAdd(data) {
  return request({
    url: '/plm-sys/api/baseObjects/add',
    method: 'post',
    data
  })
}

// 另存接口
export function putSaveanother(data) {
  return request({
    url: '/plm-sys/api/baseObjects/saveanother',
    method: 'put',
    data
  })
}

// 删除接口
export function deleteDels(data) {
  return request({
    url: '/plm-sys/api/baseObjects/dels',
    method: 'delete',
    data: data
  })
}

// 启用接口
export function putUpdateEnable(data) {
  return request({
    url: '/plm-sys/api/baseObjects/updateEnable',
    method: 'put',
    data: data
  })
}

// 禁用接口
export function putUpdateDisableEnable(data) {
  return request({
    url: '/plm-sys/api/baseObjects/updateDisableEnable',
    method: 'put',
    data: data
  })
}

// 点击单条数据查看详情
export function getView(id) {
  return request({
    url: '/plm-sys/api/baseObjects/view?id=' + id,
    method: 'get'
  })
}

// 修改物料接口
export function putUpdate(data) {
  return request({
    url: '/plm-sys/api/baseObjects/update',
    method: 'PUT',
    data: data
  })
}

// 专有属性列表接口
export function getViewAttributes(id) {
  return request({
    url: '/plm-sys/api/baseObjects/viewAttributes?id=' + id,
    method: 'get'
  })
}

// 添加属性弹框的列表接口
export function postAAQueryPageList(params) {
  return request({
    url: '/plm-sys/api/baseAttributeMaterial/queryPageList',
    method: 'post',
    data: {
      pageNo: params.pageNo,
      pageSize: params.pageSize,
      t: {
        name: params.name,
        type: params.type,
        attributeType: params.attributeType,
        status: 1
      }
    }
  })
}

// 物料添加属性保存接口
export function postAddAtrributes(data) {
  return request({
    url: '/plm-sys/api/baseObjects/addAtrributes',
    method: 'post',
    data: {
      attributeIds: data.attributeIds,
      objectId: data.objectId
    }
  })
}

// 属性顺序列表接口 对象属性查看
export function getViewObjectAttributes(id) {
  return request({
    url: '/plm-sys/api/baseObjects/viewObjectAttributes?id=' + id,
    method: 'get'
  })
}
// 属性可见
export function putUpdateVisible(data) {
  return request({
    url: '/plm-sys/api/baseObjects/updateVisible',
    method: 'put',
    data
  })
}
// 属性不可见
export function putUpdateNoVisible(data) {
  return request({
    url: '/plm-sys/api/baseObjects/updateNoVisible',
    method: 'put',
    data
  })
}

// 属性删除
export function putDeleteObjAttr(data) {
  return request({
    url: '/plm-sys/api/baseObjects/deleteObjAttr',
    method: 'put',
    data
  })
}

// 排序保存接口
export function putSaveSortObjectAttributes(data) {
  return request({
    url: '/plm-sys/api/baseObjects/saveSortObjectAttributes',
    method: 'put',
    data
  })
}
